<template>
  <div id="imagesList" v-loading="dataLoading">
    <div
      class="item"
      v-for="(item, index) in themeList"
      :key="index"
      @click="itemClick(item)"
    >
      <div :class="'link-theme ' + item.resourcesSrc">
        <div
          class="left-side"
          :style="{
            background:
              '#52cadb url(/' +
              'microPageModulesResources/images/multiPage/link/' +
              item.resourcesSrc +
              '-l.png' +
              ') no-repeat',
          }"
        >
          <i class="el-icon-link"></i>
        </div>
        <div
          class="right-side"
          :style="{
            background:
              '#52cadb url(/' +
              'microPageModulesResources/images/multiPage/link/' +
              item.resourcesSrc +
              '-r.png' +
              ') no-repeat',
          }"
        >
          <div>Tootootool</div>
        </div>
      </div>
      <div>{{ item.resourcesName }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "urlList",
  props: ["activate"],
  data() {
    return {
      loaded: false, // 是否已激活
      dataLoading: false,
      themeList: [],
    };
  },
  watch: {
    activate: {
      handler: "activateChange",
      deep: true,
    },
  },
  created() {
    this.activateChange();
  },
  mounted() {},
  methods: {
    /**
     * 监听现在激活的tab
     **/
    activateChange() {
      if (this.activate && !this.loaded) {
        // 如果未加载过，现在开始加载
        this.loaded = true;
        this.getData(); // 获取资源列表
      }
    },
    /**
     * 获取资源列表
     * @param
     */
    async getData() {
      // 走接口取数据
      this.themeList = [
        {
          resourcesName: "主题1",
          resourcesType: 5,
          resourcesSrc: "link-theme1",
        },
        {
          resourcesName: "主题2",
          resourcesType: 5,
          resourcesSrc: "link-theme2",
        },
        {
          resourcesName: "主题3",
          resourcesType: 5,
          resourcesSrc: "link-theme3",
        },
        {
          resourcesName: "主题4",
          resourcesType: 5,
          resourcesSrc: "link-theme4",
        },
      ];
    },
    /**
     * 项目点击返回该项信息
     * @param item
     */
    itemClick(item) {
      this.$emit("selectedLink", item); // 向父级传递参数
    },
  },
};
</script>

<style lang='scss' scoped>
@import "@/assets/css/linkTheme.scss";
#imagesList {
  width: 100%;
  height: 100%;
  position: relative;
  overflow-y: auto;
  .item {
    width: 100%;
    height: 85px;
    text-align: center;
    margin-bottom: 0px;
    cursor: pointer;
    img {
      width: 100px;
      height: 100px;
      display: block;
      margin: 0 auto;
      border-radius: 5px;
      -webkit-box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
  }
  .item:hover {
    img {
      -webkit-box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);
    }
  }
}
#imagesList::-webkit-scrollbar-track-piece {
  // 滚动条凹槽的颜色，还可以设置边框属性
  background-color: #f8f8f8;
}
#imagesList::-webkit-scrollbar {
  // 滚动条的宽度
  width: 6px;
  height: 6px;
}
#imagesList::-webkit-scrollbar-thumb {
  // 滚动条的设置
  background-color: #dddddd;
  background-clip: padding-box;
  min-height: 28px;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}
#imagesList::-webkit-scrollbar-thumb:hover {
  background-color: #bbb;
}
</style>
